package top.lyc829.leetcode.T191;

public class Solution {
    // you need to treat n as an unsigned value
    public int hammingWeight(int n) {
        int count = 0;
        for (int i = 0; i < 32; i++) {
            if ((n & 1) != 0) {
                count++;
            }
            n >>= 1;
        }

        return count;
    }

    public static void main(String[] args) {
        Solution s = new Solution();
        int res = s.hammingWeight(0B00000000000000000000000000001011);

        System.out.println(res);
    }
}
